/* ==================================================================   
 * Created [2009-4-27 下午11:32:55] by Jon.King 
 * ==================================================================  
 * TSS 
 * ================================================================== 
 * mailTo:jinpujun@hotmail.com
 * Copyright (c) Jon.King, 2009-2012 
 * ================================================================== 
 */

package com.jinhe.tss.cms.service;

import com.jinhe.tss.cms.entity.Article;
import com.jinhe.tss.cms.entity.ChannelArticle;
import com.jinhe.tss.cms.helper.ArticleQueryCondition;
import com.jinhe.tss.component.log.Logable;
import com.jinhe.tss.component.support.persistence.pagequery.PageInfo;

public interface IArticleService {
    /**
     * 复制文章
     * 
     * @param articleId
     * @param channelId
     * @param copyTo
     */
    @Logable(operateTable="文章", operateType="复制", operateInfo="复制(ID: ${args[0]}) 文章到(ID: ${args[1]}) 栏目下")
    void copyArticle(Long articleId, Long channelId, boolean copyTo);

    /**
     * 新增/修改文章
     * 
     * @param article
     * @param channelId
     * @param attachList
     * @param tempArticleId
     *            新增的时候上传的附件对象以new Date()为主键，此处的tempArticleId就是这个值
     */
    @Logable(operateTable="文章", operateType="新增", operateInfo="新增文章 ${args[0]} 到(ID: ${args[1]}) 栏目下")
    void createArticle(Article article, Long channelId, String attachList, Long tempArticleId);

    @Logable(operateTable="文章", operateType="修改", operateInfo="修改文章 ${args[0]}")
    void updateArticle(Article article, Long channelId, String attachList);

    /**
     * 创建普通文章栏目关系
     * 
     * @param channelId
     * @param tempArticleId
     */
    void createChannelArticleRelation(Long channelId, Long articleId);

    /**
     * 删除文章
     * 
     * @param articleId
     * @param channelId
     */
    @Logable(operateTable="文章", operateType="删除", operateInfo="删除了 ID为 ${args[0]} 的 文章 （所在栏目为：${args[1]}）")
    void deleteArticle(Long articleId, Long channelId);

    /**
     * 获取文章
     * 
     * @param articleId
     * @return
     */
    Article getArticleById(Long articleId);

    /**
     * 移动文章
     * 
     * @param articleId
     * @param oldChannelId
     * @param channelId
     */
    @Logable(operateTable="文章", operateType="移动", operateInfo="将(ID: ${args[0]}) 文章，从(ID: ${args[1]}) 栏目下移动到(ID: ${args[2]}) 栏目下")
    void moveArticle(Long articleId, Long oldChannelId, Long channelId);

    /**
     * 获取栏目下属所有文章列表
     * 
     * @param channelId
     * @param pageNum
     * @param orderBy
     * @return
     */
    PageInfo getChannelArticles(Long channelId, Integer pageNum, String... orderBy);
    
    /**
     * <p>
     * 搜索栏目下的文章
     * </p>
     * 
     * @param condition
     * @return
     */
    Object[] searchArticleList(ArticleQueryCondition condition);

    /**
     * 文章上移/下移
     * 
     * @param articleId
     * @param toArticleId
     * @param channelId
     */
    @Logable(operateTable="文章", operateType="排序", operateInfo="(ID: ${args[0]}) 和 (ID: ${args[1]})文章顺序互相交换")
    void moveArticleDownOrUp(Long articleId, Long toArticleId, Long channelId);

    /**
     * 文章跨分页上移下移
     * 
     * @param articleId
     * @param channelId
     * @param page
     * @param direction
     */
    @Logable(operateTable="文章", operateType="跨页排序", operateInfo="跨页移动文章(ID: ${args[0]})")
    void moveArticleDownOrUpCross(Long articleId, Long channelId, Integer page, int direction);

    /**
     * 锁定文章
     * 
     * @param articleId
     */
    @Logable(operateTable="文章", operateType="锁定", operateInfo="锁定(ID: ${args[0]}) 文章")
    void lockingArticle(Long articleId);

    /**
     * 解锁文章
     * 
     * @param articleId
     */
    @Logable(operateTable="文章", operateType="解锁", operateInfo="解锁(ID: ${args[0]}) 文章")
    void unLockingArticle(Long articleId);

    /**
     * 改变文章流程状态
     * 
     * @param articleId
     * @param oldStatus
     * @param status
     * @param workflowId
     */
    @Logable(operateTable="文章", operateType="走流程", operateInfo="修改(ID: ${args[0]}) 文章状态，从 ${args[1]} 到 ${args[2]}")
    void changeArticleStatus(Long articleId, Integer oldStatus, Integer status, Integer workflowId);

    /**
     * 转载文章
     * 
     * @param articleId
     * @param channelId
     * @param oldChannelId
     */
    @Logable(operateTable="文章", operateType="转载文章", operateInfo="转载(ID: ${args[0]}) 文章至 (ID: ${args[1]} 栏目下")
    void reshipArticle(Long articleId, Long channelId, Long oldChannelId);

    /**
     * 置顶文章
     * 
     * @param articleId
     * @param channelId
     */
    @Logable(operateTable="文章", operateType="置顶", operateInfo="修改(ID: ${args[0]}) 文章为 (ID: ${args[1]} 栏目的置顶文章")
    void doTopArticle(Long articleId, Long channelId);

    /**
     * 取消置顶
     * 
     * @param articleId
     * @param channelId
     */
    @Logable(operateTable="文章", operateType="解除置顶", operateInfo="取消(ID: ${args[0]}) 文章为 (ID: ${args[1]} 栏目的置顶文章")
    void undoTopArticle(Long articleId, Long channelId);

    /**
     * 获得文章的相关文章信息
     * 
     * @param articleId
     * @return
     */
    Object[] getArticleExistRelationship(Long articleId);

    /**
     * 保存文章的相关文章关系
     * 
     * @param articleId
     * @param associateArticleIds
     */
    void relatedArticleTo(Long articleId, String associateArticleIds);

    /**
     * 获得文章的分发文章关系解码器对象组
     * 
     * @param articleId
     * @param channelId
     * @return
     */
    Object[] getDistributeArticleRelationShip(Long articleId, Long channelId);

    /**
     * 保存文章的分发文章关系
     * 
     * @param articleId
     * @param channelId
     * @param distributeToChannelIds
     */
    @Logable(operateTable="文章", operateType="分发文章", operateInfo="保存(ID: ${args[0]}) 文章的分发文章关系")
    void saveDistributeArticleRelationShip(Long articleId, Long channelId, String distributeToChannelIds);

    /**
     * 根据栏目id和文章id取得栏目文章关系信息
     * 
     * @param articleId
     * @param channelId
     * @return
     */
    ChannelArticle getChannelArticle(Long articleId, Long channelId);

    /**
     * 根据权限项ID(operationId)查找用户对该流程步骤是否有权限
     * 
     * @param operationId
     *            权限项目ID
     * @param resourceId
     *            流程步骤ID
     * @return
     */
    boolean getArticleWorkflowPermission(String operationId, Long workFlowId);
}